import { defineStore } from "pinia";

export const useMapStore = defineStore('map', {
  state: () => ({
    map: [],
  }),
  actions: {
    destroyMap(x, y) {
      this.map[y][x] = 0
    },
    drawGrid(x, y, terrain) {
      this.map[y][x] = terrain
    },
    drawBlock(x, y, terrain) {
      this.map[y][x] = terrain
      this.map[y][x + 1] = terrain
      this.map[y + 1][x] = terrain
      this.map[y + 1][x + 1] = terrain
    },
    /**
     * @param {number} type
     * 1 - brick wall
     * 2 - steel wall
     */
    changeBase(type) {
      this.map[25][11] = type
      this.map[24][11] = type
      this.map[23][11] = type
      this.map[23][12] = type
      this.map[23][13] = type
      this.map[23][14] = type
      this.map[24][14] = type
      this.map[25][14] = type
    },
  }
})